lib_manager: Add cache writeback after library loading to IMR#10309
Merged
kv2019i merged 1 commit intothesofproject:mainfrom Oct 17, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a cache coherency issue in multicore scenarios where libraries loaded into IMR (Isolated Memory Region) by one core are not visible to other cores, causing crashes and errors on Intel MTL, LNL, PTL, and NVL platforms.
Key Changes:
- Added cache writeback operation after copying the library manifest to IMR
- Added cache writeback operation after copying the complete library data to IMR
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
serhiy-katsyuba-intel
approved these changes
Oct 16, 2025
c3b6e0a to
eb93619
Compare
Add dcache_writeback_region() call after copying library data to IMR (Isolated Memory Region) to ensure cache coherency in multicore scenarios. Without this cache operation, when Core 0 loads a library into IMR via memcpy_s(), the data remains in Core 0's data cache and is not written back to main memory. When Core 1 later tries to create a module from this library, it reads uninitialized or stale data from IMR, causing either: - "Unsupported module API version" errors (reading garbage build info) - Fatal PIF data errors and crashes (accessing corrupted module data) The fix adds a single cache writeback operation after all library data (manifest + module code/data) has been copied to IMR. This ensures library data written by Core 0 is flushed from cache to IMR memory before Core 1 attempts to read it, following the standard cache coherency protocol for non-coherent Harvard architecture (Xtensa). Fixes multicore topology crashes on Intel MTL, LNL, PTL, NVL platforms when loading external libraries with modules instantiated on secondary cores. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
lyakh
approved these changes
Oct 17, 2025
Collaborator
lyakh
left a comment
There was a problem hiding this comment.
alright... My only question is - why aren't Jenkins multicore nocodec tests failing left and right?..
| } | ||
|
|
||
| /* Writeback entire library to ensure it's visible to other cores */ | ||
| dcache_writeback_region((__sparse_force void *)library_base_address, preload_size); |
Collaborator
There was a problem hiding this comment.
do we continue using this API or should we gradually switch over to calling sys_cache_data_flush_range() directly?
abonislawski
approved these changes
Oct 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add dcache_writeback_region() calls after copying library data to IMR (Isolated Memory Region) to ensure cache coherency in multicore scenarios.
Without these cache operations, when Core 0 loads a library into IMR via memcpy_s(), the data remains in Core 0's data cache and is not written back to main memory. When Core 1 later tries to create a module from this library, it reads uninitialized or stale data from IMR, causing either:
The fix adds cache writeback operations at two critical points:
This ensures library data written by Core 0 is flushed from cache to IMR memory before Core 1 attempts to read it, following the standard cache coherency protocol for non-coherent Harvard architecture (Xtensa).
Fixes multicore topology crashes on Intel MTL, LNL, PTL, NVL platforms when loading external libraries with modules instantiated on secondary cores.